﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Final
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }


        //登录界面注册按钮
        private void button2_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            RegisterForm registerForm = new RegisterForm();
            registerForm.ShowDialog();
            this.Visible = true;
        }


        //登录界面登录按钮
        private void button1_Click(object sender, EventArgs e)
        {
            var name = LoginName.Text;
            var pwd = LoginPwd.Text;
            var sql = string.Format("select * from Users where UserName='{0}' and UserPwd='{1}'",name,pwd);
            var r = DBhelp.LoginRegister(sql);
            if (name=="" || pwd=="")
            {
                MessageBox.Show("用户名或密码不能为空");
            }
            else if (r==false)
            {
                MessageBox.Show("用户名或密码不正确");
            }
            else if (r)
            {
                this.Visible = false;
                FunctionForm functionForm = new FunctionForm();
                functionForm.ShowDialog();
                this.Visible = true;
            }
            else
            {
                MessageBox.Show("该用户名不存在");
            }
        }
    }
}
